@extends('admin.base.widgets')

@section('content')
    <div class="block-area" id="defaultStyle">
        <h3 class="block-title">&nbsp;&nbsp;&nbsp;分类列表</h3>
        <form action='{{ url("type") }}' method='post' name='myform'>
            {{ csrf_field() }}
            {{ method_field('delete') }}
        </form>
        <form action='/type' method='get'>
            &nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='sortName'>
            <input type='submit' class='btn' value='搜索'>
            @if (session('msg'))
                <script>alert("{{ session()->get('msg') }}")</script>
            @endif
        </form>
        <div id="mws-container" class="clearfix">
        <div class="mws-panel grid_8">
        <div class="mws-panel-body no-padding">
        <table class="mws-table">
            <thead>
                <tr>
                    <th>&nbsp;&nbsp;No.</th>
                    <th>&nbsp;&nbsp;分类名</th>
                    <th>&nbsp;&nbsp;SortPath</th>
                    <th>&nbsp;&nbsp;SortPid</th>
                    <th>&nbsp;&nbsp;操作</th>
                </tr>
            </thead>
            <tbody>
                @foreach ($list as $v)
                    <tr>
                        <td>&nbsp;&nbsp;{{ $v->SortId }}</td>
                        <td>&nbsp;&nbsp;{{ $v->SortName }}</td>
                        <td>&nbsp;&nbsp;{{ $v->SortPath }}</td>
                        <td>&nbsp;&nbsp;{{ $v->SortPid }}</td>
                        <td>
                            <a href="javascript:doDel({{ $v->SortId }})" class='btn'>删除</a>
                            <a href="{{ url('type') }}/{{ $v->SortId }}/edit" class='btn'>修改</a>
                            <a href="{{ url('typeSon').'/'.$v->SortId }}" class='btn'>添加子类</a>
                        </td>
                    </tr>
                @endforeach
            </tbody>
        </table>
        <div id="paging">{{ $list->appends($where)->links() }}</div>
        </div>
     </div>
    <script type="text/javascript">
        function doDel(id)
        {
            if(confirm('确定要删除吗？')){
                var form = document.myform;
                form.action = '/type/'+id;
                form.submit();
            }
        }
    </script>
@endsection